<?php
	require('config.php');
    $user_id=$_REQUEST['user_id'];
    $goodss_attr_id='false';
    if(isset($_REQUEST['goodss_attr_id'])) $goodss_attr_id=$_REQUEST['goodss_attr_id'];
    	$sql="select * from `".$oto."_car_session` where `userId`='".$user_id."' LIMIT 1";
		$result=$db->query($sql);
		while($row=$result->fetch_assoc()){
			$person_info[]=$row;//将取得的所有数据赋值给person_info数组
		}
		$car_session=unserialize($person_info[0]['car_session']);
		//清除购物车
        //file_put_contents("tsxx.txt", "\r\ngoodss_attr_id:".$goodss_attr_id."\r\n", FILE_APPEND);
        if($goodss_attr_id!='false')
        {
            $i=0;
            foreach($car_session as $k=>$v)
            {
                if($k==$goodss_attr_id)
                {
                    array_splice($car_session, $i, 1);
                    $i--;
                }
                $i++;
            }
        }
        else
        {
            $i=0;
            foreach($car_session as $k=>$v)
            {
                if($car_session[$k]['ischk']==1 || $car_session[$k]['ischk']=='1')
                {
                    array_splice($car_session, $i, 1);
                    $i--;
                }
                $i++;
            }
        }
		$cart_value=serialize($car_session);
        $sql="update ".$oto."_car_session set car_session='{$cart_value}' where userId='{$user_id}'";
		$result=$db->query($sql);
        if($result)
        {
            $data[0]['pan']=1;
        }
		//file_put_contents("tsxx.txt", "\r\n".$sql."执行：".$result."\r\n", FILE_APPEND);
		echo json_encode($data);
?>